//
//  FKLogisticsTopCell.m
//  BaiYeMallShop
//
//  Created by Macbook Pro on 2018/11/17.
//  Copyright © 2018 Macbook Pro. All rights reserved.
//

#import "FKLogisticsTopCell.h"

@interface FKLogisticsTopCell ()

@property (nonatomic, weak) UIImageView *iconView;
@property (nonatomic, weak) UILabel *statusLabel;
@property (nonatomic, weak) UILabel *companyLabel;
@property (nonatomic, weak) UILabel *numberLabel;

@end

@implementation FKLogisticsTopCell

- (void)setupSubviews
{
    [super setupSubviews];
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:iconView];
    self.iconView = iconView;
    
    UILabel *statusLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:statusLabel];
    self.statusLabel = statusLabel;
    
    UILabel *companyLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:companyLabel];
    self.companyLabel = companyLabel;
    
    UILabel *numberLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:numberLabel];
    self.numberLabel = numberLabel;
    
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(fk_adjustW(85));
        make.left.equalTo(self.contentView).offset(12);
        make.centerY.equalTo(self.contentView);
    }];
    [statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconView).offset(5);
        make.left.equalTo(iconView.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-12);
    }];
    [companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(statusLabel);
        make.centerY.equalTo(iconView);
    }];
    [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(iconView).offset(-5);
        make.left.right.equalTo(statusLabel);
    }];
}

- (void)setDict:(NSDictionary *)dict
{
    _dict = dict;
    
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:dict[@"goods_image"]] placeholderImage:kPlaceholder_1x1];
    self.statusLabel.text = [NSString stringWithFormat:@"物流状态: %@", dict[@"State"]];
    self.companyLabel.text = [NSString stringWithFormat:@"物流公司: %@", dict[@"express_com"]];
    self.numberLabel.text = [NSString stringWithFormat:@"运输单号: %@", dict[@"LogisticCode"]];
}

@end
